///////////////////////////////////////////////////////////
// Project 2 //
// Andrew Hains //
// Joseph Blackwell //
// Robert Smyly //
//////////////////////////
// Roomba Controller //
// Buffer.h //
///////////////////////////////////////////////////////////

#ifndef BUFFER_H
#define BUFFER_H

#include <pthread.h>
#include <semaphore.h>

typedef void* buffer_item;

typedef struct buffer_struct {
	buffer_item *items;
	int in;
	int out;
	pthread_mutex_t lock;
	sem_t full;
	sem_t empty;
	int size;
} buffer;
//typedef struct buffer_struct buffer;

/*initializes the buffer*/
int init_buffer(buffer *buff, int size);

/*Inserts a buffer_item into the buffer. Returns 0 if successful, -1 if not.*/
int buffer_insert(buffer *buff, buffer_item item);

/*Removes a buffer_item from the buffer. Returns 0 if successful, -1 if not.*/
int buffer_remove(buffer *buff, buffer_item *item);

/*destroys the buffer*/
int destroy_buffer(buffer *buff);

#endif
